import { RJSFSchema } from '@rjsf/utils';
import { TabsType } from './type';

export const GuideLine: RJSFSchema = {
  allOf: [
    {
      if: {
        properties: {
          Tabs: {
            const: TabsType.GuideLine,
          },
        },
      },
      then: {
        properties: {
          Selection: {
            type: 'object',
            title: '选项',
            properties: {
              guide: {
                title: '引导线',
                type: 'array',
                ...{
                  'x-options': [
                    {
                      const: 'node',
                      title: '节点',
                    },
                    {
                      const: 'line',
                      title: '几何线',
                    },
                  ],
                },
              },
              guideType: {
                type: 'string',
                oneOf: [
                  {
                    const: 'node',
                    title: '节点',
                  },
                  {
                    const: 'line',
                    title: '几何线',
                  },
                ],
              },
            },
          },
        },
      },
    },

    {
      if: {
        properties: {
          Tabs: {
            const: TabsType.GuideLine,
          },
          Selection: {
            type: 'object',
            properties: {
              guideType: {
                const: 'line',
              },
            },
          },
          Options: {
            type: 'object',
            properties: {
              NumberOrSize: {
                const: 'size',
              },
            },
          },
        },
      },
      then: {
        properties: {
          Options: {
            type: 'object',
            properties: {
              size: {
                type: 'number',
                title: '尺寸',
              },
            },
          },
        },
      },
    },

    {
      if: {
        properties: {
          Tabs: {
            const: TabsType.GuideLine,
          },
          Selection: {
            type: 'object',
            properties: {
              guideType: {
                const: 'line',
              },
            },
          },
        },
      },
      then: {
        properties: {
          Options: {
            type: 'object',
            title: '选项',
            properties: {
              NumberOrSize: {
                type: 'string',
                title: '拉伸方式',
                default: 'quantity',
                oneOf: [
                  {
                    const: 'quantity',
                    title: '数量',
                  },
                  {
                    const: 'size',
                    title: '尺寸',
                  },
                ],
              },
            },
          },
        },
      },
    },
    {
      if: {
        properties: {
          Tabs: {
            const: TabsType.GuideLine,
          },
          Selection: {
            type: 'object',
            properties: {
              guideType: {
                const: 'line',
              },
            },
          },
          Options: {
            type: 'object',
            title: '选项',
            properties: {
              NumberOrSize: {
                const: 'quantity',
              },
            },
          },
        },
      },
      then: {
        properties: {
          Options: {
            type: 'object',
            title: '选项',
            properties: {
              count: {
                type: 'number',
                title: '数量',
              },
            },
          },
        },
      },
    },
    {
      if: {
        properties: {
          Tabs: {
            const: TabsType.GuideLine,
          },
          Selection: {
            type: 'object',
            properties: {
              guideType: {
                const: 'line',
              },
            },
          },
          Options: {
            type: 'object',
            title: '选项',
            properties: {
              NumberOrSize: {
                const: 'size',
              },
            },
          },
        },
      },
      then: {
        properties: {
          Options: {
            type: 'object',
            properties: {
              size: {
                type: 'number',
                title: '尺寸',
              },
            },
          },
        },
      },
    },
    {
      if: {
        properties: {
          Selection: {
            type: 'object',
            properties: {
              Tabs: {
                const: TabsType.GuideLine,
              },
              guideType: {
                const: 'line',
              },
            },
          },
        },
      },
      then: {
        properties: {
          Options: {
            type: 'object',
            properties: {
              reverse: {
                type: 'boolean',
                title: '反向',
              },
            },
          },
        },
      },
    },
  ],
};
